package com.one.square.user.server.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.one.square.core.domain.Result;
import com.one.square.core.entity.SysDictType;
import com.one.square.core.vo.QuerySysDictTypeVo;
import com.one.square.user.server.service.SysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author cwm
 * @Description 数据字典信息
 * @date 2021/11/1 上午10:45
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/dict/type")
@AllArgsConstructor
@Api(value = "/sys/dict/type", tags = {"数据字典信息"})
public class SysDictTypeController {
    private final SysDictTypeService service;

    @GetMapping("/list")
    @ApiOperation(value = "条件查询字典信息列表")
    public Result<IPage> list(Page<SysDictType> page, QuerySysDictTypeVo querySysDictTypeVo) {
        return service.list(page, querySysDictTypeVo);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加字典信息")
    public Result add(@RequestBody SysDictType sysDictType) {
        service.add(sysDictType);
        return Result.succeed("添加成功");
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改字典信息")
    public Result update(@RequestBody SysDictType sysDictType) {
        service.update(sysDictType);
        return Result.succeed("修改成功");
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除字典信息")
    public Result delete(@RequestParam(value = "id") Long id) {
        service.removeById(id);
        return Result.succeed("删除成功");
    }
}
